//
//  RegisterViewController.m
//  02-HomeWork
//
//  Created by dllo on 16/7/15.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "RegisterViewController.h"
#import "LoginViewController.h"
@interface RegisterViewController () <UITextFieldDelegate>
@property (nonatomic, strong) UITextField *phoneTextField;
@property (nonatomic, strong) UITextField *verificationTextField;
@end

@implementation RegisterViewController

- (void)viewWillAppear:(BOOL)animated {
    self.navigationController.navigationBar.barStyle = UIBarStyleBlack;
}

//register
- (void)viewDidLoad {
    
    [super viewDidLoad];
    self.navigationItem.title = @"注册";
    UIBarButtonItem *backBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"<返回" style:UIBarButtonItemStylePlain target:self action:@selector(backLoginButtonClicked)];
    self.navigationItem.leftBarButtonItem = backBarButtonItem;
    //backGround
    UIImageView *backGroundImageView = [[UIImageView alloc] initWithFrame:[UIScreen mainScreen].bounds];
    backGroundImageView.image = [UIImage imageNamed:@"welcome_2.jpg"];
    [self.view addSubview:backGroundImageView];
    //logo
    UIImageView *logoImageView = [[UIImageView alloc] initWithFrame:CGRectMake(self.view.frame.size.width / 2, 70, 180, 220)];
    CGPoint point = logoImageView.center;
    point.x = self.view.frame.size.width / 2;
    logoImageView.center = point;
    logoImageView.image = [UIImage imageNamed:@"logo_lagou@2x.png"];
    [self.view addSubview:logoImageView];
    //输入框
    UILabel *inputLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 300, self.view.frame.size.width - 20, 110)];
        //    inputLabel.backgroundColor = [UIColor whiteColor];
    inputLabel.layer.cornerRadius = 8;
    inputLabel.clipsToBounds = YES;
    //    inputLabel.layer.borderWidth = 4;
    //    label和imageView都要开用户交互
    inputLabel.userInteractionEnabled = YES;
    [self.view addSubview:inputLabel];
    // 手机登录
    UIImageView *phoneLoginImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 50, 50)];
    phoneLoginImageView.image = [UIImage imageNamed:@"phone.png"];
    phoneLoginImageView.backgroundColor = [UIColor colorWithRed:0.16 green:0.11 blue:0.06 alpha:1.00];
    [inputLabel addSubview:phoneLoginImageView];
    self.phoneTextField = [[UITextField alloc] initWithFrame:CGRectMake(50, 0, 310, 50)];
    self.phoneTextField.backgroundColor = [UIColor grayColor];
    self.phoneTextField.alpha = 0.4;
    self.phoneTextField.textColor = [UIColor whiteColor];
    self.phoneTextField.placeholder = @"请输入手机号";
    self.phoneTextField.textColor = [UIColor whiteColor];
    self.phoneTextField.delegate = self;
    [inputLabel addSubview:self.phoneTextField];
    
    UIImageView *verificationImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 60, 50, 50)];
    verificationImageView.image = [UIImage imageNamed:@"verification.png"];
    verificationImageView.backgroundColor = [UIColor colorWithRed:0.16 green:0.11 blue:0.06 alpha:1.00];
    [inputLabel addSubview:verificationImageView];
    self.verificationTextField = [[UITextField alloc] initWithFrame:CGRectMake(50, 60, 310, 50)];
    self.verificationTextField.backgroundColor = [UIColor grayColor];
    self.verificationTextField.alpha = 0.4;
    self.verificationTextField.placeholder = @"请输入验证码";
    self.verificationTextField.delegate = self;
    [inputLabel addSubview:self.verificationTextField];
    
    UIButton *getVerificationButton = [UIButton buttonWithType:UIButtonTypeCustom];
    getVerificationButton.frame = CGRectMake(250, 60, 100, 50);
    [getVerificationButton setTitle:@"获取验证码" forState:UIControlStateNormal];
    [getVerificationButton setTitleColor:[UIColor colorWithRed:0.00 green:0.68 blue:0.53 alpha:1.00] forState:UIControlStateNormal];
    [getVerificationButton addTarget:self action:@selector(getVerification) forControlEvents:UIControlEventTouchUpInside];
    [inputLabel addSubview:getVerificationButton];
    
    // 提示信息
    UILabel *promptLabel = [[UILabel alloc] initWithFrame:CGRectMake(20, 420, self.view.frame.size.width - 40, 40)];
    promptLabel.textAlignment = NSTextAlignmentCenter;
    promptLabel.text = @"注册代表你以同意拉钩用户协议";
    promptLabel.textColor = [UIColor colorWithRed:0.00 green:0.68 blue:0.53 alpha:1.00];
    [self.view addSubview:promptLabel];
    
    // 注册按钮
    UIButton *registerButton = [UIButton buttonWithType:UIButtonTypeCustom];
    registerButton.frame = CGRectMake(20, 460, self.view.frame.size.width - 40, 40);
    registerButton.backgroundColor = [UIColor colorWithRed:0.00 green:0.68 blue:0.53 alpha:1.00];
    registerButton.layer.cornerRadius = 4;
    [registerButton setTitle:@"注册" forState:UIControlStateNormal];
    [registerButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [registerButton addTarget:self action:@selector(registerButtonClicked) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:registerButton];
    // 返回登录
    UIButton *backLoginButton = [UIButton buttonWithType:UIButtonTypeCustom];
    backLoginButton.frame = CGRectMake(20, 530, self.view.frame.size.width - 40, 40);
    backLoginButton.layer.cornerRadius = 4;
    backLoginButton.layer.borderWidth = 2;
    backLoginButton.layer.borderColor = [UIColor colorWithRed:0.00 green:0.68 blue:0.53 alpha:1.00].CGColor;
    [backLoginButton setTitle:@"返回登录" forState:UIControlStateNormal];
    [backLoginButton setTitleColor:[UIColor colorWithRed:0.00 green:0.68 blue:0.53 alpha:1.00] forState:UIControlStateNormal];
    [backLoginButton addTarget:self action:@selector(backLoginButtonClicked) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:backLoginButton];
}
- (void)getVerification {
    
}
- (void)registerButtonClicked {
    
}
- (void)backLoginButtonClicked {
    [self.phoneTextField resignFirstResponder];
    [self.verificationTextField resignFirstResponder];

    [self.navigationController popViewControllerAnimated:YES];
}
  //收起键盘
- (void)touchesEnded:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
    if (![self.phoneTextField isExclusiveTouch] || ![self.verificationTextField isExclusiveTouch]) {
        [self.phoneTextField resignFirstResponder];
        [self.verificationTextField resignFirstResponder];
    }
}

- (BOOL)textFieldShouldReturn:(UITextField *)textField {
    [textField endEditing:YES];
    return YES;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
